package com.huajin.codetest.base;

public class StringTest {
	
	public static void main(String[] args) {
//		String str = null;
//		//-- 使用+进行拼接实际上是会转换为StringBuilder使用append方法进行拼接
//        str = str + "";
//        System.out.println(str);//-- null，通过查看编译之后的字节码
//        StringBuilder sb = new StringBuilder();
//        sb.append(str);
//        sb.append("");
//        System.out.println(sb.toString());//-- null
		
		
		String s1 = "ab";
		String s2 = "a" + "b";
		System.out.println(s1 == s2);//true 字符串常量
		String s3 = "a";
		String s4 = "b";
		String s5 = s3 + s4;
		System.out.println(s2 == s5);//false
		
		Integer i1 = 100;
		Integer i2 = Integer.valueOf(100);
		Integer i3 = new Integer(100);
		System.out.println(i1 == i2);//true 常量池
		System.out.println(i1 == i3);//false
		
		Integer i4 = 1000;
		Integer i5 = Integer.valueOf(1000);
		Integer i6 = new Integer(1000);
		System.out.println(i4 == i5);//false
		System.out.println(i4 == i6);//false
		
		
	}
	
}
